package com.awesome.kotlindemo.function.extend

import android.view.SurfaceHolder

/**
 * Author: zhangjingfang
 * Email:zhangjingfang@jeejio.com
 * Date: 2021/11/25
 * Description:类描述
 */
fun SurfaceHolder.addCallback(
    surfaceCreated: (holder: SurfaceHolder) -> Unit = { _ -> },
    surfaceChanged: (holder: SurfaceHolder, format: Int, width: Int, height: Int) -> Unit = { _, _, _, _ -> },
    surfaceDestroyed: (holder: SurfaceHolder) -> Unit = { _ -> }
) {
    addCallback(object : SurfaceHolder.Callback {
        override fun surfaceCreated(holder: SurfaceHolder) {
            surfaceCreated(holder)
        }

        override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
            surfaceChanged(holder, format, width, height)
        }

        override fun surfaceDestroyed(holder: SurfaceHolder) {
            surfaceDestroyed(holder)
        }

    })
}